<template>
  <view class="dbox bd">
    <u-input
      v-model="value"
      maxlength="300"
      :type="type"
      :border="border"
      :height="height"
      :auto-height="autoHeight"
      :clearable="false"
    />
    <u-button class="btn" @tap="submit">提交建议</u-button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      value: "",
      type: "textarea",
      border: true,
      height: 600,
      autoHeight: false,
    };
  },
  onReady() {
    // this.getUiStyle();
  },
  methods: {
    getUiStyle() {
      var style = plus.navigator.getUiStyle();
      if ("dark" == style) {
        console.log("当前为暗黑模式");
        uni.setTabBarStyle({
          backgroundColor: "#1B1C1E",
        });
        uni.setNavigationBarColor({
          frontColor: "#ffffff",
          backgroundColor: "#1B1C1E",
          animation: {
            duration: 400,
            timingFunc: "easeIn",
          },
        });
      } else {
        console.log("当前为普通模式");
      }
    },
    submit() {
      let self = this;
      uni.showLoading({
        title: "加载中",
        mask: true,
      });
      setTimeout((s) => {
        uni.hideLoading();
      }, 5000);
      this.config
        .post("/feedbackData/submit", {
          content: self.value,
        })
        .then((res) => {
          uni.hideLoading();
          if (res.data.code === 200) {
            uni.showToast({
              title: res.data.msg,
            });
            self.value = "";
            setTimeout((s) => {
              uni.navigateBack();
            }, 500);
          } else {
            if (res.data.code == "-201") {
              self.config.handleError(res.data);
            } else {
              uni.showToast({
                title: self.config.handleError(res.data),
                icon: "none",
              });
            }
          }
        });
    },
  },
};
</script>
<style lang="less" scoped>
.dbox {
  padding: 20rpx;

  .btn {
    margin-top: 30rpx;
    background-color: #18c7e1;
    color: #fff;
    background-color: #18c7e1;
  }
}
</style>
<style scoped>
@media (prefers-color-scheme: closedark) {
  .bd {
    background-color: #1b1c1e !important;
    margin-top: -5px;
    height: 120vh;
    width: 100%;
    position: fixed;
  }

  .bd1 {
    background-color: #38383c !important;
  }

  .t1 {
    color: #ccc !important;
  }
  >>> textarea {
    color: #ccc !important;
  }
}
</style>
